package com.kalle.workflow.query;

import com.kalle.workflow.elements.SequenceFlow;
import com.kalle.workflow.mapper.SequenceFlowMapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SequenceFlowQuery extends AbstractQuery<SequenceFlow> {

    private final SequenceFlowMapper sequenceFlowMapper;

    private final Map<String, Object> conditionMap;

    public SequenceFlowQuery(SequenceFlowMapper sequenceFlowMapper) {
        this.sequenceFlowMapper = sequenceFlowMapper;
        this.conditionMap = new HashMap<>();
    }

    public SequenceFlowQuery deploymentId(String deploymentId) {
        conditionMap.put("deploymentId", deploymentId);
        return this;
    }

    public SequenceFlowQuery processKey(String processKey) {
        conditionMap.put("processKey", processKey);
        return this;
    }

    public SequenceFlowQuery name(String name) {
        conditionMap.put("name", name);
        return this;
    }

    public SequenceFlowQuery sourceRefId(String sourceRefId) {
        conditionMap.put("sourceRefId", sourceRefId);
        return this;
    }

    public SequenceFlowQuery targetRefId(String targetRefId) {
        conditionMap.put("targetRefId", targetRefId);
        return this;
    }

    @Override
    List<SequenceFlow> list() {
        return sequenceFlowMapper.list(conditionMap);
    }

}
